home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / ixpipe / misc.h < prev    next >
Text File  |  1993-11-15  |  2KB  |  66 lines

  1. /*
  2.  *  misc.c  - support routines - Phillip Lindsay (C) Commodore 1986
  3.  *  You may freely distribute this source and use it for Amiga Development -
  4.  *  as long as the Copyright notice is left intact.
  5.  *
  6.  * 30-SEP-86
  7.  *
  8.  */
  9.  
  10. /* I converted this source to ANSI-C and made it a header file, so the
  11.    functions can be included inline into the source. Inlining will only
  12.    work with compilers that support it, like gcc.
  13.  
  14.    1992-07-03 Markus Wild    */
  15.  
  16.  
  17. /* returnpkt() - packet support routine
  18.  * here is the guy who sends the packet back to the sender...
  19.  *
  20.  * (I modeled this just like the BCPL routine [so its a little redundant] )
  21.  */
  22.  
  23. static inline void
  24. returnpkt (struct DosPacket *packet, struct Process *myproc, 
  25.        ULONG res1, ULONG res2)
  26. {
  27.   struct Message *mess;
  28.   struct MsgPort *replyport;
  29.  
  30.   packet->dp_Res1          = res1;
  31.   packet->dp_Res2          = res2;
  32.   replyport                = packet->dp_Port;
  33.   mess                     = packet->dp_Link;
  34.   packet->dp_Port          = &myproc->pr_MsgPort;
  35.   mess->mn_Node.ln_Name    = (char *) packet;
  36.   mess->mn_Node.ln_Succ    =
  37.     mess->mn_Node.ln_Pred  = 0;
  38.   PutMsg (replyport, mess);
  39. }
  40.  
  41.  
  42. static inline void
  43. returnpktplain (struct DosPacket *packet, struct Process *myproc)
  44. {
  45.   returnpkt (packet, myproc, packet->dp_Res1, packet->dp_Res2);
  46. }
  47.  
  48.  
  49. /*
  50.  * taskwait() ... Waits for a message to arrive at your port and
  51.  *   extracts the packet address which is returned to you.
  52.  */
  53.  
  54. static inline struct DosPacket *
  55. taskwait (struct Process *myproc)
  56. {
  57.   struct MsgPort *myport;
  58.   struct Message *mymess;
  59.  
  60.   myport = &myproc->pr_MsgPort;
  61.   WaitPort (myport);
  62.   mymess = GetMsg (myport);
  63.   return ((struct DosPacket *)mymess->mn_Node.ln_Name);
  64. }
  65.  
  66.